<html>
<head><meta charset="utf-8"><title>MCP: Elevated privileges for #[test_util] lang-team#38 · t-lang/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/index.html">t-lang/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html">MCP: Elevated privileges for #[test_util] lang-team#38</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205022620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205022620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205022620">(Jul 25 2020 at 21:37)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/lang-team/issues/38">#38</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="205025556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205025556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205025556">(Jul 25 2020 at 23:02)</a>:</h4>
<p>Original discussion: <a href="#narrow/stream/219381-t-libs/topic/Elevated.20priviliges.20for.20.23.5Btest_util.5D">https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Elevated.20priviliges.20for.20.23.5Btest_util.5D</a></p>



<a name="205027625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205027625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205027625">(Jul 26 2020 at 00:02)</a>:</h4>
<p>How does this interact with the test-only-visibility proposal that was mentioned here at some point?</p>



<a name="205028360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205028360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205028360">(Jul 26 2020 at 00:26)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> I can't find the proposal you're talking about in either <a href="https://github.com/rust-lang/lang-team/issues?q=is%3Aissue+is%3Aopen+test">https://github.com/rust-lang/lang-team/issues?q=is%3Aissue+is%3Aopen+test</a> or searching zulip. Do you have a link?</p>



<a name="205028574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205028574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205028574">(Jul 26 2020 at 00:32)</a>:</h4>
<p>Hmm, no. Maybe it was somewhere else.</p>



<a name="205032618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205032618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205032618">(Jul 26 2020 at 02:48)</a>:</h4>
<p>I don't think it's been formally proposed, but test visibility is roughly <code>pub(if cfg!(test))</code>. If the <code>cfg!</code> is <code>pub(if true)</code>, the item is <code>pub</code>. If the <code>cfg!</code> is <code>pub(if false)</code>, the item is <code>pub(self)</code> (as if <code>pub</code> had not been written).</p>



<a name="205032757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205032757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205032757">(Jul 26 2020 at 02:52)</a>:</h4>
<p>Various syntaxes have been floated, from the obvious <code>pub(test)</code> which is ambiguous (with <code>pub (test)</code>, as parametized visibility must start with a keyword) to <code>pub(#[cfg(..)] in path)</code> which would be a more general way to conditionally raise the visibility.</p>



<a name="205032830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205032830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205032830">(Jul 26 2020 at 02:54)</a>:</h4>
<p>Personally I think allowing <code>pub(if $macro_call)</code> which would expands to a new allowed <code>pub(if $bool_lit)</code> is enough; more complicated cases would just end up being an intelligible micro language better served by just using the currently stable workaround of defining the thing twice with the correct visibility under a <code>#[cfg]</code>.</p>



<a name="205033554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205033554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205033554">(Jul 26 2020 at 03:19)</a>:</h4>
<p>That sounds fine to me <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="205033559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205033559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205033559">(Jul 26 2020 at 03:19)</a>:</h4>
<p>You get all the benefit of this proposal but it's more flexible and requires only a small change to the language</p>



<a name="205033598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205033598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205033598">(Jul 26 2020 at 03:20)</a>:</h4>
<p>Plus less bikeshedding hopefully</p>



<a name="205033620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205033620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205033620">(Jul 26 2020 at 03:21)</a>:</h4>
<p>Personally I would support <code>pub(#[cfg])</code> just because it's very self-evident what that does</p>



<a name="205043793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205043793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wodann <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205043793">(Jul 26 2020 at 09:17)</a>:</h4>
<p>That proposal sounds even better to me. As you said, it covers a wider range of use cases. E.g. your proposed <code>pub(#[cfg])</code> would also cover integration tests.</p>



<a name="205070995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205070995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205070995">(Jul 26 2020 at 23:02)</a>:</h4>
<p><code>pub(#[cfg])</code> for visibility is only syntactically viable if we say we never will support attributes on the types in a tuple</p>



<a name="205071060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205071060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205071060">(Jul 26 2020 at 23:04)</a>:</h4>
<p>The reason <code>pub(visibility)</code> is required to start with a keyword is so that <code>struct Tuple ( pub ( &gt;|&lt;</code> can know whether you've just opened a parenthesized type or a <code>pub(restrict)</code> in fixed lookahead</p>



<a name="205766598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205766598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wodann <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205766598">(Aug 03 2020 at 07:36)</a>:</h4>
<p>Wouldn't the parser be able to detect both <code>struct Tuple ( pub ( &gt;|&lt;</code> and <code>struct Tuple ( pub ( #[ &gt;|&lt;</code>? I'd prefer a design that scales to all <code>pub</code> use cases, as it would be counterintuitive if the pattern works for some but not all <code>pub( ... )</code></p>



<a name="205821399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205821399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205821399">(Aug 03 2020 at 17:16)</a>:</h4>
<p>As I said, it's viable (without unbounded lookahead or backtracking) if and only if we commit to never having attributes inside tuple types</p>



<a name="205821501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205821501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205821501">(Aug 03 2020 at 17:17)</a>:</h4>
<p>E.g. should <code>(#[cfg(x86)] u32, #[cfg(x64)] u64, usize)</code> ever be a valid type?</p>



<a name="205821712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205821712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205821712">(Aug 03 2020 at 17:18)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=ef508d28fc3e51abb611b6046c3ac41c">It is valid as a named Tuple type</a></p>



<a name="205823051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205823051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205823051">(Aug 03 2020 at 17:31)</a>:</h4>
<p>As a different argument, with <code>pub(#[cfg(X)] in path)</code>, what's the visibility when the cfg is false? Simple removal would suggest <code>pub()</code> (illegal form) or <code>pub</code> (globally public).</p>
<p>That really doesn't seem a useful interpretation; you typically want "elevate visibility if" not "elevate visibility if not", and if the point of <code>#[cfg]</code> forms is flexibility, it's still falling back to globally visible, so it's not flexible enough.</p>
<p>If you say to well, use <code>cfg_if!</code> so you have an explicit fallback, what do you say <code>cfg_if!</code> should even expand to? We don't have <code>pub(restrict, restrict)</code> forms, and what would that even mean? The repetition and multiple restrictions is required for a multiple-choice <code>#[cfg]</code> solution, even if it only ever expands to one actual restriction, because we can't know that until after expanding the cfgs, so the language has to support multiple restrictions at the same time.</p>
<p>It's also fairly simple to set up a proc-macro to create a set of <code>#[cfg]</code>d exports forwarding to a single impl, so my argument is that the simple <code>pub(if $bool_or_macro_bool)</code> is more than enough.</p>



<a name="205846010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205846010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205846010">(Aug 03 2020 at 20:51)</a>:</h4>
<blockquote>
<p>fairly simple to set up a proc-macro</p>
</blockquote>
<p>Here's a proof-of-concept I threw together: <a href="https://github.com/CAD97/cfg-pub">https://github.com/CAD97/cfg-pub</a></p>



<a name="205846088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/205846088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#205846088">(Aug 03 2020 at 20:52)</a>:</h4>
<p>It doesn't do anything clever like forwarding to a single impl that's always present, it just copy-pastes the item with the different attributes and visibility, to make it simpler.</p>



<a name="206002489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/206002489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wodann <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#206002489">(Aug 05 2020 at 09:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="132829">Christopher Durham</span> <a href="#narrow/stream/243200-t-lang.2Fmajor-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338/near/205821501">said</a>:</p>
<blockquote>
<p>E.g. should <code>(#[cfg(x86)] u32, #[cfg(x64)] u64, usize)</code> ever be a valid type?</p>
</blockquote>
<p>I didn't know that was possible. In that case, you can make a field <code>pub</code> for tests-only within a crate <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=e62793f7a1c1a52ced289e2a7e947339">already</a>.</p>



<a name="206003140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/206003140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wodann <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#206003140">(Aug 05 2020 at 09:26)</a>:</h4>
<p>I agree with all of the caveats that you've brought forth. In the end the goal would be to expose some (tuple) struct fields only for tests. The approach that I had in mind when creating this MCP was:</p>
<blockquote>
<p>As a test writer I want to have access to non-pub fields (or methods) in a function that cannot have the <code>#[test]</code> attribute.</p>
</blockquote>
<p>An alternative could however also be:</p>
<blockquote>
<p>Specifically for tests, I expose these non-pub fields (or methods).</p>
</blockquote>
<p>I am not sure which approach is more desirable for writing clear and concise code, nor whether it is even possible to have an out-of-crate integration test access a <code>#[cfg(test)] pub field</code>. I'll do some more investigation for that.</p>



<a name="206021873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/206021873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#206021873">(Aug 05 2020 at 13:30)</a>:</h4>
<p>a compiler flag for just blanket "this is testing mode, ignore visibility, trust me i know what I'm doing" without a specific configuration anywhere seems fine in the scheme of things.</p>
<p>Presumably it would only work for types within the same crate, but actually there's no reason it couldn't just work for all types everywhere. Obviously if the user uses such a flag they've jumped well outside of normal semver/safety/sanity.</p>



<a name="206022376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/206022376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#206022376">(Aug 05 2020 at 13:35)</a>:</h4>
<p>All types everywhere seems like overkill</p>



<a name="206022391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/206022391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#206022391">(Aug 05 2020 at 13:35)</a>:</h4>
<p>The use case for this in <a href="http://docs.rs">docs.rs</a> is that we want to benchmark private functions</p>



<a name="206022406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/206022406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#206022406">(Aug 05 2020 at 13:35)</a>:</h4>
<p>But we don't need access to anything private in our dependencies</p>



<a name="206023853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/206023853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#206023853">(Aug 05 2020 at 13:49)</a>:</h4>
<p>I don't personally use workspaces, but some people seem to be in love with having a sprawling crate graph. For that situation, it seems easily possible that you'd want a test to inspect the internals of "another crate" (but still your overall project).</p>



<a name="206025405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Elevated%20privileges%20for%20%23%5Btest_util%5D%20lang-team%2338/near/206025405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wodann <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Elevated.20privileges.20for.20.23.5Btest_util.5D.20lang-team.2338.html#206025405">(Aug 05 2020 at 14:02)</a>:</h4>
<p>As far as I know, <a href="https://doc.rust-lang.org/rust-by-example/testing/integration_testing.html">integration tests</a> are also "outside" of the crate - even though they are actually part of the crate's project structure.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>